//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.come.until;

import com.tool.role.RoleData;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import javax.swing.tree.DefaultMutableTreeNode;
import org.come.Jpanel.GoodsMsgJpanel;
import org.come.Jpanel.StorageJadeJpanel;
import org.come.Jpanel.StorageJadeJpanel2;
import org.come.Jpanel.StorageJadeJpanel3;
import org.come.Jpanel.StorageJadeJpanel4;
import org.come.bean.IncludedPart;
import org.come.bean.JadeorGoodstableBean;
import org.come.bean.RoleSuitBean;
import org.come.entity.Goodstable;
import org.come.entity.PartJade;

public class AccessSuitMsgUntil {
    public static int exvalue = 3;

    public AccessSuitMsgUntil() {
    }

    public static void showSuitMethod(DefaultMutableTreeNode top, boolean bool) {
        top.removeAllChildren();
        if (UserMessUntil.getAllSuit().getRolesuit() != null) {
            Iterator iterator = UserMessUntil.getAllSuit().getRolesuit().entrySet().iterator();

            while(iterator.hasNext()) {
                Entry<Integer, RoleSuitBean> entry = (Entry)iterator.next();
                boolean bool2 = true;
                int suitid = returnSuitID(((RoleSuitBean)entry.getValue()).getSname());
                DefaultMutableTreeNode node = new DefaultMutableTreeNode(((RoleSuitBean)entry.getValue()).getSname());
                List<String> partlist = returnPartsList(((RoleSuitBean)entry.getValue()).getHaveParts());
                if (partlist != null && partlist.size() > 0) {
                    for(int i = 0; i < partlist.size(); ++i) {
                        node.add(new DefaultMutableTreeNode(returnPartsName((String)partlist.get(i))));
                        int partId = Integer.parseInt((String)partlist.get(i));
                        if (bool2) {
                            bool2 = RoleData.getRoleData().getPackRecord().getPartJade(suitid, partId).isJade();
                        }
                    }
                }

                if (!bool) {
                    if (!bool2) {
                        top.add(node);
                    }
                } else {
                    top.add(node);
                }
            }

        }
    }

    public static List<Goodstable> accessIdlEqu(int type) {
        List<Goodstable> listEqui = new ArrayList();

        for(int i = 0; i < GoodsListFromServerUntil.getGoodslist().length; ++i) {
            if (GoodsListFromServerUntil.getGoodslist()[i] != null) {
                long goodid = GoodsListFromServerUntil.getGoodslist()[i].getGoodsid().longValue();
                long goodtype = GoodsListFromServerUntil.getGoodslist()[i].getType();
                if (Goodtype.EquipmentType(goodtype) != -1 && Goodtype.EquipmentType(goodtype) != 0 && Goodtype.EquipmentType(goodtype) != 4 && Goodtype.EquipmentType(goodtype) != 5 && goodid != 6029L && goodid != 6030L && goodid != 6031L && goodid != 6032L && goodid != 6033L && goodid != 6034L) {
                    if (type == 2) {
                        if (GoodsListFromServerUntil.getGoodslist()[i].getValue().indexOf("套装属性") != -1) {
                            listEqui.add(GoodsListFromServerUntil.getGoodslist()[i]);
                        }
                    } else if (type == 1 && GoodsListFromServerUntil.getGoodslist()[i].getValue().indexOf("套装属性") == -1) {
                        listEqui.add(GoodsListFromServerUntil.getGoodslist()[i]);
                    }
                }
            }
        }

        return listEqui;
    }

    public static int getCollNum(int suitid) {
        int num = 0;
        List<IncludedPart> parts = getIncludedMsg(suitid);
        if (parts == null) {
            return 0;
        } else {
            for(int i = 0; i < parts.size(); ++i) {
                if (((IncludedPart)parts.get(i)).getNumber() > 0) {
                    ++num;
                }
            }

            return num;
        }
    }

    public static List<IncludedPart> getIncludedMsg(int suitid) {
        List<IncludedPart> listMsg = new ArrayList();
        List<String> parts = returnPartsList(((RoleSuitBean)UserMessUntil.getAllSuit().getRolesuit().get(suitid)).getHaveParts());
        String[] v = RoleData.getRoleData().getPackRecord().getCollect(suitid);

        for(int i = 0; i < parts.size(); ++i) {
            IncludedPart part = new IncludedPart();
            part.setPartid((String)parts.get(i));
            if (v == null) {
                part.setNumber(0);
            } else {
                boolean bool = false;

                for(int j = 0; j < v.length; ++j) {
                    if (v[j].equals(parts.get(i))) {
                        bool = true;
                    }
                }

                if (bool) {
                    part.setNumber(1);
                } else {
                    part.setNumber(0);
                }
            }

            listMsg.add(part);
        }

        return listMsg;
    }

    public static boolean isActivate(List<IncludedPart> parts, int index) {
        boolean bool = true;

        for(int i = 0; i < parts.size(); ++i) {
            if (((IncludedPart)parts.get(i)).getNumber() == 0 && i != index) {
                bool = false;
            }
        }

        return bool;
    }

    public static void refreshJadeShow(PartJade jade) {
        if (StorageJadeJpanel3.partJade != null && StorageJadeJpanel3.partJade.getSuitid() == jade.getSuitid() && StorageJadeJpanel3.partJade.getPartId() == jade.getPartId()) {
            StorageJadeJpanel3.partJade = jade;
        }

        if (StorageJadeJpanel4.partJade != null && StorageJadeJpanel4.partJade.getSuitid() == jade.getSuitid() && StorageJadeJpanel4.partJade.getPartId() == jade.getPartId()) {
            StorageJadeJpanel4.partJade = jade;
        }

        if (StorageJadeJpanel.partJade != null && StorageJadeJpanel.partJade.getSuitid() == jade.getSuitid() && StorageJadeJpanel.partJade.getPartId() == jade.getPartId()) {
            StorageJadeJpanel.partJade = jade;
        }

        if (StorageJadeJpanel2.partJade != null && StorageJadeJpanel2.partJade.getSuitid() == jade.getSuitid() && StorageJadeJpanel2.partJade.getPartId() == jade.getPartId()) {
            StorageJadeJpanel2.partJade = jade;
        }

    }

    public static List<String> getSuitAttr(String attr) {
        if (attr == null) {
            return null;
        } else {
            List<String> attribute = new ArrayList();
            String[] attrs = attr.split("\\&");

            for(int i = 4; i < attrs.length; ++i) {
                String[] ss = attrs[i].split("\\=");
                attribute.add(ss[0]);
                attribute.add(ss[1] + GoodsMsgJpanel.tianjia(ss[0]));
            }

            return attribute;
        }
    }

    public static String getExtra(String value, String extra) {
        String[] v = value.split("\\|");

        for(int i = 0; i < v.length; ++i) {
            if (v[i].length() >= 4 && v[i].substring(0, 4).equals(extra)) {
                return v[i];
            }
        }

        return null;
    }

    public static String returnnewEx(int type, String value) {
        String[] attrs = value.split("\\&");
        String newEx = "";
        String pz = attrs[3];
        if (type == 0) {
            newEx = pz;
        } else {
            int index;
            if (type == 1) {
                index = returnJadeType(pz) + 1;
                StringBuffer buffer = new StringBuffer();

                for(int i = 0; i < attrs.length; ++i) {
                    if (i != 0) {
                        buffer.append("&");
                    }

                    if (i != 3) {
                        buffer.append(attrs[i]);
                    } else {
                        buffer.append(returnJadeName(index));
                    }
                }

                newEx = buffer.toString();
            } else if (type == 3) {
                index = returnJadeType(pz) + 1;
                newEx = returnJadeName(index);
            }
        }

        return newEx;
    }

    public static int getSxlxz(String value) {
        int sxlxz = 0;
        String key = returnnewEx(0, getExtra(value, "套装属性"));
        switch(key.hashCode()) {
            case 647926:
                if ("传世".equals(key)) {
                    sxlxz = 160;
                }
                break;
            case 811615:
                if ("把玩".equals(key)) {
                    sxlxz = 10;
                }
                break;
            case 828695:
                if ("无价".equals(key)) {
                    sxlxz = 80;
                }
                break;
            case 953250:
                if ("珍藏".equals(key)) {
                    sxlxz = 40;
                }
                break;
            case 1157111:
                if ("贴身".equals(key)) {
                    sxlxz = 20;
                }
        }

        return sxlxz;
    }

    public static BigDecimal returnMoney(JadeorGoodstableBean goodstableBean, int type) {
        if (goodstableBean.getGoodstable() != null && goodstableBean.getPartJade() != null && goodstableBean.getType() != 0) {
            BigDecimal big = new BigDecimal(0);
            if (type == 1) {
                big = new BigDecimal(1000000);
            } else if (type == 2) {
                big = new BigDecimal(1000000);
            }

            return big;
        } else {
            return null;
        }
    }

    public static List<String> returnPartsList(String parts) {
        List<String> partlist = new ArrayList();
        if (parts != null && !"".equals(parts)) {
            String[] v = parts.split("\\|");

            for(int i = 0; i < v.length; ++i) {
                partlist.add(v[i]);
            }
        }

        return partlist;
    }

    public static Integer returnSuitID(String sname) {
        int id = -1;
        if (UserMessUntil.getAllSuit().getRolesuit() == null) {
            return null;
        } else {
            Iterator iterator = UserMessUntil.getAllSuit().getRolesuit().entrySet().iterator();

            while(iterator.hasNext()) {
                Entry<Integer, RoleSuitBean> entry = (Entry)iterator.next();
                if (((RoleSuitBean)entry.getValue()).getSname().equals(sname)) {
                    id = (Integer)entry.getKey();
                    break;
                }
            }

            return id == -1 ? null : id;
        }
    }

    public static String returnPartsName(String id) {
        String pname = null;
        if ("1".equals(id)) {
            pname = "帽子";
        } else if ("2".equals(id)) {
            pname = "项链";
        } else if ("3".equals(id)) {
            pname = "衣服";
        } else if ("6".equals(id)) {
            pname = "面具";
        } else if ("7".equals(id)) {
            pname = "腰带";
        } else if ("8".equals(id)) {
            pname = "披风";
        } else if ("9".equals(id)) {
            pname = "挂件";
        } else if ("10".equals(id)) {
            pname = "左戒指";
        } else if ("11".equals(id)) {
            pname = "右戒指";
        }

        return pname;
    }

    public static Integer returnPartsID(String pname) {
        int id = -1;
        if ("帽子".equals(pname)) {
            id = 1;
        } else if ("项链".equals(pname)) {
            id = 2;
        } else if ("衣服".equals(pname)) {
            id = 3;
        } else if ("面具".equals(pname)) {
            id = 6;
        } else if ("腰带".equals(pname)) {
            id = 7;
        } else if ("披风".equals(pname)) {
            id = 8;
        } else if ("挂件".equals(pname)) {
            id = 9;
        } else if ("左戒指".equals(pname)) {
            id = 10;
        } else if ("右戒指".equals(pname)) {
            id = 11;
        }

        return id == -1 ? null : Integer.valueOf(id);
    }

    public static String returnJadeName(int type) {
        String name = "把玩";
        switch(type) {
            case 1:
                name = "把玩";
                break;
            case 2:
                name = "贴身";
                break;
            case 3:
                name = "珍藏";
                break;
            case 4:
                name = "无价";
                break;
            case 5:
                name = "传世";
        }

        return name;
    }

    public static int returnJadeType(String name) {
        int index = 0;
        switch(name.hashCode()) {
            case 647926:
                if ("传世".equals(name)) {
                    index = 5;
                }
                break;
            case 811615:
                if ("把玩".equals(name)) {
                    index = 1;
                }
                break;
            case 828695:
                if ("无价".equals(name)) {
                    index = 4;
                }
                break;
            case 953250:
                if ("珍藏".equals(name)) {
                    index = 3;
                }
                break;
            case 1157111:
                if ("贴身".equals(name)) {
                    index = 2;
                }
        }

        return index;
    }

    public static int returnJadeNum(int type) {
        int num = 0;
        switch(type) {
            case 1:
                num = 5;
                break;
            case 2:
                num = 4;
                break;
            case 3:
                num = 3;
                break;
            case 4:
                num = 3;
        }

        return num;
    }

    public static BigDecimal returnJadeMoney(int type) {
        BigDecimal num = null;
        switch(type) {
            case 1:
                num = new BigDecimal(1000000);
                break;
            case 2:
                num = new BigDecimal(1000000);
                break;
            case 3:
                num = new BigDecimal(1000000);
                break;
            case 4:
                num = new BigDecimal(1000000);
        }

        return num;
    }

    public static int returnExcNum(int type) {
        int num = 0;
        switch(type) {
            case 1:
                num = 1;
                break;
            case 2:
                num = 1;
                break;
            case 3:
                num = 2;
                break;
            case 4:
                num = 2;
                break;
            case 5:
                num = 3;
        }

        return num;
    }

    public static String getPalEquipAgree(String value, String type) {
        String[] split = value.split("\\|");

        for(int i = 0; i < split.length; ++i) {
            if (split[i].startsWith(type)) {
                return split[i];
            }
        }

        return null;
    }
}
